package negocio;

import java.util.Date;
import java.util.GregorianCalendar;

public class Utilidades {

	
	public static Date geraDate(String data) throws NumberFormatException {
		
		String[] dataStr = data.trim().split("/");
		GregorianCalendar cal = new GregorianCalendar();
		cal.set(Integer.parseInt(dataStr[2]),
				Integer.parseInt(dataStr[1]) - 1,
				Integer.parseInt(dataStr[0]));
		return cal.getTime();
		
	}
	
	public static String geraDataString(Date data) {
		
		GregorianCalendar cal = new GregorianCalendar();
		cal.setTime(data);
		String result = String.format("%02d",cal.get(GregorianCalendar.DAY_OF_MONTH)) +
				"/" + String.format("%02d",cal.get(GregorianCalendar.MONTH)+1) +
				"/" + String.format("%04d",cal.get(GregorianCalendar.YEAR));
		return result;
		
	}
}




